<?php

namespace app\model;

use support\Db;
use support\Model;

class WaBillCode
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'wa_bill_code';

    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $primaryKey = 'id';

    /**
     * Indicates if the model should be timestamped.
     *
     * @var bool
     */
    public $timestamps = false;

    /**
     * 款项列表 - 分页
     * @return false|string
     */
    public static function list($page, $pageNum, $fields,$condition)
    {
        $list = Db::table('wa_bill_code')
            ->select($fields)
            ->where($condition)
            ->orderBy('id', 'asc')
            ->get();
        return json_encode($list);
    }


    /**
     *
     * 款项列表 - 不分页
     * @param $fields
     * @param $condition
     * @return false|string
     */
    public static function all($condition)
    {
        $list = Db::table('wa_bill_code')
            ->select('*')
            ->where($condition)
            ->get();

        return json_encode($list);
    }

    public static function find($condition)
    {
        $res = Db::table('wa_bill_code')
            ->where($condition)
            ->first();
        return json_encode($res);
    }

    public static function created($data){

        return Db::table('wa_bill_code')->insertGetId($data);

    }

    public static function updated($condition,$data){

        $res = Db::table('wa_bill_code')->where($condition)->update($data);
        return json_encode($res);

    }


}